module.exports = {
	apps: [{
		name: 'n8n-main',
		script: './packages/cli/bin/n8n',
		// 使用 pnpm exec 启动
		exec_interpreter: 'pnpm',
		exec_mode: 'fork',
		args: 'start',
		env: {
			N8N_HOST: '0.0.0.0',
			N8N_PORT: 5678,
			N8N_PROTOCOL: 'http',
			GENERIC_TIMEZONE: 'Asia/Shanghai',

			EXECUTIONS_MODE: 'queue',

			DB_TYPE: 'postgresdb',
			DB_POSTGRESDB_HOST: '192.168.22.32',
			DB_POSTGRESDB_PORT: '5432',
			DB_POSTGRESDB_DATABASE: 'n8n',
			DB_POSTGRESDB_USER: 'n8n_user',
			DB_POSTGRESDB_PASSWORD: 'Fanzha@2024',

			QUEUE_BULL_REDIS_HOST: '192.168.22.32',
			QUEUE_BULL_REDIS_PORT: 6379,
			QUEUE_BULL_REDIS_PASSWORD: 'Fanzha@2024',
			QUEUE_BULL_REDIS_DB: 0,

			N8N_ENCRYPTION_KEY: 'random', // 必须与 worker 一致

			N8N_LOG_LEVEL: 'info',
			N8N_RUN_MIGRATIONS_ON_STARTUP: true
		},
		autorestart: true,
		max_memory_restart: '4G',
		error_file: './logs/main-err.log',
		out_file: './logs/main-out.log',
		log_date_format: 'YYYY-MM-DD HH:mm:ss'
	}]
};
